using System;
using System.Reflection;
using System.Web.UI.WebControls;
using Sedna.Core.Tiles.Contents;

namespace Sedna.Core.Controls
{
	public class BuildIndicatorControl : WebControl, IContent
	{
		private String contentPlaceHolderId;

		public String ContentPlaceHolderId
		{
			get { return contentPlaceHolderId;}
			set { contentPlaceHolderId = value;}
		}

		protected override void Render(System.Web.UI.HtmlTextWriter writer)
		{
			base.Render (writer);

			string showBuildAndConnection = System.Configuration.ConfigurationManager.AppSettings.Get("showBuildAndConnection");
			if(showBuildAndConnection == null || !("true"==showBuildAndConnection.ToLower()))
			{
				return;
			}

			Version eeVersion = Assembly.LoadWithPartialName("Sedna").GetName().Version;

//			writer.Write(String.Format("Sedna Build: {0}.{1}.{2}.{3}; CoreBaseLib Build: {4}.{5}.{6}.{7}; Database connection string: {8}",
//					eeVersion.Major, eeVersion.Minor, eeVersion.Build, eeVersion.Revision, 
//					libVersion.Major, libVersion.Minor, libVersion.Build, libVersion.Revision,
//					System.Configuration.ConfigurationSettings.AppSettings.Get("connection.string")
//				));

			writer.Write(String.Format("Sedna Build: {0}.{1}.{2}.{3};",
					eeVersion.Major, eeVersion.Minor, eeVersion.Build, eeVersion.Revision
				));

		}

	}
}
